package maquinavotar.view;

import java.awt.Button;
import java.awt.Label;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import maquinavotar.MaquinaVotarApp;
import maquinavotar.dao.VoteDAOImplXml;

public class ConfirmVoteScreen extends JPanel {
    
    public ConfirmVoteScreen(final MaquinaVotarApp app) {
        
        this.add(new Label("Confirme su voto"));
        
        Button btn_confirm = new Button("Confirmar");
        btn_confirm.addMouseListener(new java.awt.event.MouseAdapter() {
                @Override
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    JOptionPane.showMessageDialog(null, "Voto realizado exitosamente. Puede retirar su tarjeta.", "Confirmación de voto", JOptionPane.INFORMATION_MESSAGE);

                    VoteDAOImplXml v = new VoteDAOImplXml();
                    v.saveVoto(app.vote);
                    
                    app.vote = null;
                    
                    app.showScreen(0,2);
                }
            });
        this.add(btn_confirm);
        
        Button btn_edit = new Button("Editar");
        btn_edit.addMouseListener(new java.awt.event.MouseAdapter() {
                @Override
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    app.showScreen(1,2);
                }
            });
        this.add(btn_edit);
    }

}